<?
include('../db/koneksi.php');
$nm_tbl=$_POST['nm_tbl'];
$result = mysql_query("SHOW COLUMNS FROM $nm_tbl");
$resultx = mysql_query("SHOW COLUMNS FROM $nm_tbl");
$resultxx = mysql_query("SHOW COLUMNS FROM $nm_tbl");
$judul_atas=split('_',strtolower($nm_tbl));
$jum_atas=count($judul_atas);
$title='Form Input';
for($a=0;$a<$jum_atas;$a++){
$title=$title.' '.ucwords($judul_atas[$a]);
}
$l=1;
if (mysql_num_rows($resultxx) > 0) {
	while ($rowxx = mysql_fetch_assoc($resultxx)) {
	$index[$l]=strtolower($rowxx['Field']);
	$l++;
	}
	
	}
?>
<hr>

<code>

&lt;?<br>
include('../tools/form.php');<br>
include('../head.php');<br>
$kode=$_GET['kode'];<br>
$result= select_table('<?=$nm_tbl ?>', '2','<?=$index[1]?>',"$kode");//untuk Kode di sesuaikan dengan table cth kd_siswa<br>
while($row = mysql_fetch_array($result)){<br>
	<?
		if (mysql_num_rows($resultx) > 0) {
			while ($rowx = mysql_fetch_assoc($resultx)) { ?>
				$<?=strtolower($rowx['Field']);?>=$row['<?=strtolower($rowx['Field']);?>'];<br>
			<?}
		}
	?>
}<br>

form_buka('<?=$nm_tbl?>_edit_submit.php');<br>
//============================= Judul Form ========================<br>
judul('<?=$title?>');<br>
//============================= Isi Form ==========================<br>
?&gt;
<?
//$arrNama=split(",",$nama);
//$arrLabel=split(",",$label);
//$jumlah_kolom = count($arrNama);
$j=1;
if (mysql_num_rows($result) > 0) {//cek kalo ada fieldnyaa

echo "&lt;table style='width:100%;' &gt; ";
    while ($row = mysql_fetch_assoc($result)) {
	if($j%2==1){echo '&lt;tr&gt;';};
	$yap=split('_',strtolower($row['Field']));
	$jenis=$row['Type'];
	$jum=count($yap);
	$judul=null;
	for($i=0;$i<$jum;$i++){
	$judul=$judul.' '.ucwords($yap[$i]);
	}
	
	if($jenis=='date'||$jenis=='datetime')
	{ ?>
	&lt;td&gt;
		&lt;?kalender('<?=$judul?>','<?=strtolower($row['Field']);?>',"value='$<?=strtolower($row['Field']);?>'");?&gt;<br>
		&lt;/td&gt;
	<? }else{
	?>
	&lt;td&gt;
        &lt;?input('<?=$judul?>','<?=strtolower($row['Field']);?>',"value='$<?=strtolower($row['Field']);?>'");?&gt;<br>
	&lt;/td&gt;	
  <? 
  
} 
if($j%2==0){echo '&lt;/tr&gt;<br>';};
  $j++;
 }
if($j%2==0){
echo '&lt;td&gt;&nbsp;&lt;/td&gt;&lt;/tr&gt;';
}
//echo '&lt;/tr&gt;<br>';
echo "&lt;tr&gt;&lt;td colspan='2' align='center'  &gt; &lt;br&gt; &lt;?  button('submit','Simpan');
button('reset','Kosong');?&gt; &lt;/td&gt;&lt;/tr&gt;";
echo '&lt;/table&gt;';
}

?>
&lt;?
//============================= Button ============================<br>

form_tutup();
?&gt;


</code>